package vistas.clientes;
import java.util.List;
import javax.swing.JButton;

import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JSeparator;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;

import app.Odv;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class ListaUnCliente extends javax.swing.JFrame {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JLabel jLabel1;
	private JLabel jLabel2;
	private JComboBox jComboBox1;
	private JButton jButton1;
	private JTextArea jTextArea1;
	private JSeparator jSeparator1;
	private JTextField jTextFieldNumero;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				ListaUnCliente inst = new ListaUnCliente();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public ListaUnCliente() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			{
				jLabel1 = new JLabel();
				getContentPane().add(jLabel1);
				jLabel1.setText("INGRESE EL NUMERO");
				jLabel1.setBounds(12, 31, 139, 16);
			}
			{
				jLabel2 = new JLabel();
				getContentPane().add(jLabel2);
				jLabel2.setText("DE CLIENTE");
				jLabel2.setBounds(12, 53, 93, 16);
			}
			{
				jTextFieldNumero = new JTextField();
				getContentPane().add(jTextFieldNumero);
				jTextFieldNumero.setBounds(151, 39, 48, 23);
			}
			{
				
				
				Odv s= Odv.getinstancia();
				List<String>lista = s.listaId();
				
				
				
				
				jComboBox1 = new JComboBox();
				getContentPane().add(jComboBox1);
				
				
				for(String i : lista)
					jComboBox1.addItem(i);
				
				
				
				
				jComboBox1.setBounds(274, 39, 53, 23);
				jComboBox1.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						System.out.println("jComboBox1.actionPerformed, event="+evt);
						
						String i= (String) jComboBox1.getSelectedItem();
						
						jTextFieldNumero.setText(i);
						
						
						
					}
				});
			}
			{
				jSeparator1 = new JSeparator();
				getContentPane().add(jSeparator1);
				jSeparator1.setBounds(0, 136, 383, 10);
			}
			{
				jTextArea1 = new JTextArea();
				getContentPane().add(jTextArea1);
				jTextArea1.setBounds(0, 144, 384, 118);
			}
			{
				jButton1 = new JButton();
				getContentPane().add(jButton1);
				jButton1.setText("LISTAR");
				jButton1.setBounds(12, 89, 80, 23);
				jButton1.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						System.out.println("jButton1.actionPerformed, event="+evt);
						
						Odv s = Odv.getinstancia();
						String str=s.imprimirCliente(jTextFieldNumero.getText());
						
						if(str!=null)
						jTextArea1.setText(str);
						
						else{
							ErrorId v = new ErrorId();
							v.setVisible(true);
							v.setLocationRelativeTo(null);
						}
							
						
						
						
						
						
						
					}
				});
			}
			pack();
			setSize(400, 300);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

}
